using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;

public partial class Admin_SuaKhachhang : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            LoadData();
    }
    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            txt_makh.Text = id.ToString();

            tbKhachhang khachhang = tbKhachhangBUS.GetByID(id);
            txt_tenkh.Text = khachhang.Tenkh.ToString();
            txt_taikhoan.Text = khachhang.Taikhoan.ToString();
            txt_matkhau.Text = khachhang.Matkhau.ToString();
            txt_dienthoai.Text = khachhang.Sodthoai.ToString();
            txt_email.Text = khachhang.Email.ToString();
            txt_diachi.Text = khachhang.Diachi.ToString();
        }
        catch
        {
            Response.Redirect("~/Admin/DanhsachKhachhang.aspx");
        }
    }
    protected void btn_sua_Click(object sender, EventArgs e)
    {
        try
        {
            int id = int.Parse(Request.QueryString["iD"].ToString());
            tbKhachhang khachhang = tbKhachhangBUS.GetByID(id);
            khachhang.Tenkh = txt_tenkh.Text;
            khachhang.Taikhoan = txt_taikhoan.Text;
            khachhang.Matkhau = txt_matkhau.Text;
            khachhang.Sodthoai = txt_dienthoai.Text;
            khachhang.Email = txt_email.Text;
            khachhang.Diachi = txt_diachi.Text;

            tbKhachhangBUS.Update(khachhang);
        }
        catch
        {

        }
        Response.Redirect("~/Admin/DanhsachKhachhang.aspx");
        Response.Redirect(Request.RawUrl);
    }
}
